<!DOCTYPE html>
<html>
<head>
    <title>What's on TV now</title>

    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta name="description" content="South African TV schedule optimized for your mobile phone or iPhone." />
    <meta name="viewport" content="width=device-width" />
    <meta name="google-site-verification" content="YAXa389BJc4pcKT2W3j1Ne1L3dByELD6rIkqgL1FUV4" />

    <link type="text/css" rel="stylesheet" href="/stylesheets/main.min.css" media="all" />
    <link type="text/css" rel="stylesheet" href="/stylesheets/mobile.min.css" media="handheld" />

    {% if supports_javascript %}
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" async="" ></script>
    {% endif %}
    <script type="text/javascript">
      window.google_analytics_uacct = "UA-374538-8";
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-374538-8']);
      _gaq.push(['_setCustomVar', 1, 'ua', '{{useragent}}'.substring(0, 62)]);
      _gaq.push(['_setCustomVar', 1, 'fe', '{{features}}'.substring(0, 62)]);
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    </script>
</head>

<body>
    <div id="content">
        <div id="usergreeting">
        {% if uname %}
            Hello <em>{{uname}}</em>&nbsp;&nbsp;<span class="smaller"><a href="{{ulink}}" >[logout]</a></span>
        {% else %}
            Hello <em>Guest</em>&nbsp;&nbsp;<span class="smaller"><a href="{{ulink}}" >[login]</a></span>
        {% endif %}
            </div>
        <form id="input" action="search" method="post">
            <table class="layout"><tr><td class="labelcell">Search:</td><td class="maincell">
            <input type="text" name="search" title="search" /></td><td>
            <input type="submit" value="search" /></td></tr></table>
        </form>

        <form id="input2" action="/" method="get" class="auto_submit">
            <table class="layout"><tr><td class="labelcell">Display next:</td><td class="maincell">
            <select name="next" title="next">
              <option value="2">&nbsp;2 hours</option>
              <option value="4" selected="selected" >&nbsp;4 hours</option>
              <option value="6">&nbsp;6 hours</option>
              <option value="12">12 hours</option>
              <option value="18">18 hours</option>
              <option value="24">24 hours</option>
            </select></td><td>
            <input type="submit" value="submit" /></td></tr></table>
        </form>

        {% if timenow and next%}
        <h3 class="time">Showing programs for the next {{next}} hours from {{timenow}}</h3>
        {% endif %}

        {% if search %}
        You searched for: <b>{{search}}</b>&nbsp;&nbsp;<span class="smaller"><a href="/" >[clear]</a><span>
        {% endif %}

        {% if supports_javascript and not mobile %}
        <div id="ad" >
            <script type="text/javascript">
                google_ad_client = "pub-6434860662276804";
                /* tvgogga large ad 468x60, created 3/1/10 */
                google_ad_slot = "8694135819";
                google_ad_width = 468;
                google_ad_height = 60;
            </script>
            <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
        </div>
        {% endif %}
        {% if supports_javascript and mobile %}
        <div id="mob_ad" >
            <script type="text/javascript">
                window.googleAfmcRequest = {
                    client: 'ca-mb-pub-6434860662276804',
                    format: '320x50_mb',
                    output: 'html',
                    slotname: '6261282760',
                };
            </script>
            <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_afmc_ads.js"></script>
        </div>
        {% endif %}

    {% if data %}
    {% regroup data|dictsort:"channel" by channel as grouped %}

      {% for group in grouped %}
        {{group.grouper}}
        <table class="channeltable">
            {% for program in group.list|dictsort:"sort" %}
            <tr class="{{program.class}}">

                            <td class="start">{{program.start}}</td>
                            <td class="click middle">
                                {% if not supports_javascript %}
                                <a class="right" href="#{{program.key}}" onclick="toggle('{{program.key}}')">
                                    <img src="images/plus.png" alt="expand" title="expand" /></a>
                                {% endif %}
                                <a class="prog" id="{{program.key}}" href="/more?key={{program.key}}"
                                    title="{{program.desc}}">{{program.title}}</a>
                                <div class="desc" id="{{program.key}}_div"></div>
                            </td>
                            <td class="rating">{% if program.rating %}{{program.rating}}{% endif %} </td>
                            <td class="end">{{program.stop}}</td>
                            {% if uname %}
                            <td class="favourite"><a href="add?keyword={{program.title}}" class="favourite" ><img src="images/heart.png" alt="&lt;3" title="add to favourites" /></a></td>
                            {% endif %}
            </tr>
            {% endfor %}
        </table>
      {% endfor %}

    {% else %}
        <div>Nothing to show :(</div>
    {% endif %}

        <div id="footer">
            {% if debug %}
            <div class="update"><a href="./reload">reload</a></div>

                {% if entries and lastupdate %}
            <div class="update">Last update was at {{lastupdate}} ({{entries}})</div>
                {% endif %}
            <div class="update">[ {{useragent}} ]</div>
            <div class="update">{{features}}</div>
            {% endif %}
            <div class="update">A creation by <a href="http://bluegray.co.za/" title="bluegray Web Design">bluegray WD &copy; 2012</a></div>
        </div>

    </div>
    <script type="text/javascript">
      /* To load scripts after DOMContentLoaded */
      function load_defered(script_src) {
        var script_var = document.createElement('script');
        script_var.type = 'text/javascript';
        script_var.src = script_src;
        document.body.appendChild(script_var);
      };

      function downloadJSAtOnload() {
        load_defered('/javascript/custom.min.js');
      }

      if (window.addEventListener)
        window.addEventListener("load", downloadJSAtOnload, false);
      else
        if (window.attachEvent)
          window.attachEvent("onload", downloadJSAtOnload);
        else
          window.onload = downloadJSAtOnload;
    </script>
</body>
</html>

